import React, {Component} from 'react';
import PropTypes from 'prop-types';
import Item from '../Item';
import './index.css';

export default class List extends Component {

	// 限制props传值
	static propTypes = {
		todoList: PropTypes.array.isRequired,
		updateTodo: PropTypes.func.isRequired,
		deleteOneTodo:PropTypes.func.isRequired
	};

	render() {
		const {todoList, updateTodo,deleteOneTodo} = this.props;

		return (
			<ul className="todo-main">
				{todoList.map(item => {
					return <Item key={item.id} {...item} updateTodo={updateTodo} deleteOneTodo={deleteOneTodo}/>;
				})}
			</ul>
		);
	}
}
